    //
//  Menu_iPad.m
//  PokerIn
//
//  Created by sunrui-MacBook on 11-7-20.
//  Copyright 2011 139.ME. All rights reserved.
//

#import "Menu_iPad.h"
#import "VipViewController.h"
#import "ShareViewController.h"
#import "PersonalViewController.h"
#import "FriendsViewController.h"
#import "ShopViewController.h"
#import "SettingViewController.h"
#import "LetterViewController.h"
#import "LoginViewController.h"

@implementation Menu_iPad
@synthesize currentUsr;
@synthesize delegate;
- (void)setCurrentUsr:(UsrInfo) usr{
	
	currentUsr = usr;
	
	printf("%p,%p,%s",&currentUsr,&usr,currentUsr.usrNick);
	
	//name.text = [NSString stringWithFormat:@"%s",currentUsr.usrNick];
	name.text = [NSString stringWithCharacters:(unichar *)usr.usrNick length:SizeofUnichar((unichar *)usr.usrNick)];
	chouma.text = [NSString stringWithFormat:@"%lld",usr.usrCounters];
	jinbi.text = [NSString stringWithFormat:@"%d",usr.usrCoins];
	jibie.text = [NSString stringWithFormat:@"%d",usr.usrExperience];
	
	//NSLog(@"name.txt:%@",name.text);
	
	
	
	
}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Overriden to allow any orientation.
    return YES;
}


- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc. that aren't in use.
}


- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
	NSLog(@"Menu_iPad dealloc");
	if (poper) {
		[poper dismissPopoverAnimated:NO];
		[poper release];
	}
    [super dealloc];
	
}
#pragma mark ---BtnPress---

-(IBAction)login{
    [delegate login];
}

-(IBAction)vipPress{
    VipViewController *vip=[[VipViewController alloc]init];
    if (poper) {
        [poper dismissPopoverAnimated:NO];
        [poper release];
        poper=nil;
    }
    poper=[[UIPopoverController alloc]initWithContentViewController:vip];
    NSArray *array=[NSArray arrayWithObjects:loginBtn,shareBtn,personalBtn,friendsBtn,shopBtn,settingBtn,letterBtn,nil];
    poper.passthroughViews=array;
    poper.popoverContentSize = CGSizeMake(500, 320);
    [poper presentPopoverFromRect:CGRectMake(337, 83, 0, 0) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    [vip release];
    //[vipPoper release];
}
-(IBAction)sharePress{
    ShareViewController *share=[[ShareViewController alloc]init];
    
    if (poper) {
        [poper dismissPopoverAnimated:NO];
        [poper release];
        poper=nil;
    }
    poper=[[UIPopoverController alloc]initWithContentViewController:share];
    NSArray *array=[NSArray arrayWithObjects:vipBtn,personalBtn,friendsBtn,shopBtn,settingBtn,letterBtn,nil];
    poper.passthroughViews=array;
    
    poper.popoverContentSize = CGSizeMake(232, 129);
    [poper presentPopoverFromRect:CGRectMake(687, 83, 0, 0) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    [share release];
    
    
}

-(IBAction)personalPress{
    PersonalViewController *per=[[PersonalViewController alloc]init];
    if (poper) {
        [poper dismissPopoverAnimated:NO];
        [poper release];
        poper=nil;
    }
    poper=[[UIPopoverController alloc]initWithContentViewController:per];
    NSArray *array=[NSArray arrayWithObjects:vipBtn,shareBtn,friendsBtn,shopBtn,settingBtn,letterBtn,nil];
    poper.passthroughViews=array;
    poper.popoverContentSize = CGSizeMake(500, 319);
    [poper presentPopoverFromRect:CGRectMake(752, 83, 0, 0) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    [per release];
}
-(IBAction)friendsPress{
    FriendsViewController *friends=[[FriendsViewController alloc]init];
    if (poper) {
        [poper dismissPopoverAnimated:NO];
        [poper release];
        poper=nil;
    }
    poper=[[UIPopoverController alloc]initWithContentViewController:friends];
    NSArray *array=[NSArray arrayWithObjects:vipBtn,personalBtn,shareBtn,shopBtn,settingBtn,letterBtn,nil];
    poper.passthroughViews=array;
    poper.popoverContentSize = CGSizeMake(421, 319);
    [poper presentPopoverFromRect:CGRectMake(812, 83, 0, 0) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    [friends release];
}
-(IBAction)shopPress{
    ShopViewController *shop=[[ShopViewController alloc]init];
    if (poper) {
        [poper dismissPopoverAnimated:NO];
        [poper release];
        poper=nil;
    }
    poper=[[UIPopoverController alloc]initWithContentViewController:shop];
    NSArray *array=[NSArray arrayWithObjects:vipBtn,friendsBtn,personalBtn,shareBtn,settingBtn,letterBtn,nil];
    poper.passthroughViews=array;
    poper.popoverContentSize = CGSizeMake(500, 320);
    [poper presentPopoverFromRect:CGRectMake(872, 83, 0, 0) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    [shop release];
}
-(IBAction)settingPress{
    SettingViewController *set=[[SettingViewController alloc]init];
    if (poper) {
        [poper dismissPopoverAnimated:NO];
        [poper release];
        poper=nil;
    }
    poper=[[UIPopoverController alloc]initWithContentViewController:set];
    NSArray *array=[NSArray arrayWithObjects:vipBtn,friendsBtn,shopBtn,personalBtn,shareBtn,letterBtn,nil];
    poper.passthroughViews=array;
    poper.popoverContentSize = CGSizeMake(370, 366);
    [poper presentPopoverFromRect:CGRectMake(930, 83, 0, 0) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    [set release];
}
-(IBAction)letterPress{
    LetterViewController *letter=[[LetterViewController alloc]init];
    if (poper) {
        [poper dismissPopoverAnimated:NO];
        [poper release];
        poper=nil;
    }
    poper=[[UIPopoverController alloc]initWithContentViewController:letter];
    NSArray *array=[NSArray arrayWithObjects:vipBtn,settingBtn,friendsBtn,shopBtn,personalBtn,shareBtn,nil];
    poper.passthroughViews=array;
    poper.popoverContentSize = CGSizeMake(500, 320);
    [poper presentPopoverFromRect:CGRectMake(995, 83, 0, 0) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    [letter release];
}

@end